package com.autosalon.ui.automobil.action;

import com.autosalon.ui.automobil.Automobil;
import com.autosalon.ui.automobil.state.AutomobilStateHolder;
import com.vaadin.ui.Button.ClickEvent;

/**
 *  Nastaveni stavu pro zobrazeni automobilu
 * @author Petr Kriegisch
 */
public class ViewAutomobilAction extends AbstractAutomobilAction {

    public ViewAutomobilAction(Automobil automobil) {
        super(automobil);
    }

    @Override
    public void buttonClick(ClickEvent event) {
        int id;
        try {
            id = automobil.getSwitcher().getMainWindow().getZakaznik().getRole().getId().intValue();
        } catch (NullPointerException e) {
            id = 1;
        }
        AutomobilStateHolder.setState(AutomobilStateHolder.VIEW_AUTOMOBIL_STATE, id, super.automobil);

    }
}
